import { Key } from 'react'

//1.引入封装的axios请求
import { request } from "@/utils/http";



//3.引入请求参数的类型,3.2引入返回值的类型
import type {
  getHosSetListParamsType,
  getHosSetListReturnType,
  addHospitalParamType,
  getHosSetListItemsType,
  updateHospitalParamType
} from './model/hospitalSetTypes'

//2.在医院设置中,请求分页列表
export const getHosSetListRequest = ({page ,limit,hosname,hoscode}:getHosSetListParamsType)=>{
  return request.get<any,getHosSetListReturnType>(`/admin/hosp/hospitalSet/${page}/${limit}`,{
    params:{
        hosname,
        hoscode
    }
    // git请求的两个参数,第二个就是返回值,所以数据类型就是返回值数据类型
  })
}


// 3.医院设置-新增医院请求
export const addHospitalRequest = (data:addHospitalParamType)=>{
  return request.post<any,null>('/admin/hosp/hospitalSet/save',data)
}

//4.1医院设置中 根据id获取某个详细的医院设置
export const getHosSetFromIdRequest = (id:string)=>{
  return request.get<any,getHosSetListItemsType>(`/admin/hosp/hospitalSet/get/${id}`)
}
// 4.2医院设置中 根据id修改数据后，再次提交修改
export const updateHosSetFromIdRequest = (data:updateHospitalParamType) =>{
  return request.put('/admin/hosp/hospitalSet/update',data)
}

// 5.医院色设置中根据id删除某条数据
export const deleteHosSetFromIdRequest = (id:number)=>{
  return request.delete<any,null>(`/admin/hosp/hospitalSet/remove/${id}`)
}

//6.医院设置中 批量删除数据
export const batchDeleteHosRequest = (ids: Key[]) => {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/batchRemove`, {
    data: ids
  })
}